<?php 

	//接收ajax传递的参数
	$uname = $_POST['name'];

	$pdo = new PDO('mysql:host=localhost;dbname=lamp154;charset=utf8;port=3306','root','');

	$stmt = $pdo->query('select * from user1 where username = "'.$uname.'"');

	//提取结果
	$res = $stmt->fetch();


	//判断用户名是否可用
	if(empty($res)){
		//为空用户名可用
		echo 1;
	}else{
		echo 0;
	}

 ?>